package com.example.jl.bethinner.activity;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.TextView;

import com.example.jl.bethinner.R;
import com.example.jl.bethinner.base.BaseActivity;

public class ValueAnimatorActivity extends BaseActivity {
//  学习地址 http://blog.csdn.net/guolin_blog/article/details/43536355

    private TextView textview;
    AnimatorSet animSet;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_value_animator);

        textview = (TextView) findViewById(R.id.test_view);

        float curTranslationX = textview.getTranslationX();

        ObjectAnimator moveIn = ObjectAnimator.ofFloat(textview, "translationX", curTranslationX, 500f, curTranslationX);//初始位置，移动距离，结束位置
        ObjectAnimator rotate = ObjectAnimator.ofFloat(textview, "rotation", 0f, 360f);
        ObjectAnimator fadeInOut = ObjectAnimator.ofFloat(textview, "alpha", 1f, 0f, 1f);
        animSet = new AnimatorSet();
        animSet.play(rotate).with(fadeInOut).after(moveIn);
        animSet.setDuration(5000);

        textview.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                animSet.start();
            }
        });
    }


}
